﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using ERP_RORZE_SYSTEM;

namespace ERP_RORZE_DLL.Assembly
{
    public partial class panel_F5DirectIndirect : UserControl
    {
        private INISettings mySetting;
        private SqlConnection myConnection;

        public panel_F5DirectIndirect()
        {
            InitializeComponent();            

            this.mySetting = new INISettings();
            this.myConnection = new SqlConnection(mySetting.SQLConnectionString);
            this.subGroup.SelectedIndex = 0;
            this.yearText.Text = DateTime.Now.Year.ToString();
        }

        private void buttonView_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(this.yearText.Text.Trim()))
            {
                MessageBox.Show("Please enter Year to view report");
            }
            else
            {
                switch (this.subGroup.SelectedIndex)
                {
                    case 0:
                        reportDocument.DocumentSource = null;
                        rpt_F5DirectIndirect F5DirectIndirect = new rpt_F5DirectIndirect();
                        F5DirectIndirect.year = this.yearText.Text.Trim();
                        F5DirectIndirect.LoadData();
                        F5DirectIndirect.CreateDocument();
                        reportDocument.DocumentSource = F5DirectIndirect;
                        break;                        
                    case 1:
                        reportDocument.DocumentSource = null;
                        rpt_F5DirectIndirectMouter F5DirectIndirectMouter = new rpt_F5DirectIndirectMouter();
                        F5DirectIndirectMouter.year = this.yearText.Text.Trim();
                        F5DirectIndirectMouter.LoadData();
                        F5DirectIndirectMouter.CreateDocument();
                        reportDocument.DocumentSource = F5DirectIndirectMouter;
                        break;
                    case 2:
                        reportDocument.DocumentSource = null;
                        rpt_F5DirectIndirectAssembly F5DirectIndirectAssembly = new rpt_F5DirectIndirectAssembly();
                        F5DirectIndirectAssembly.year = this.yearText.Text.Trim();
                        F5DirectIndirectAssembly.LoadData();
                        F5DirectIndirectAssembly.CreateDocument();
                        reportDocument.DocumentSource = F5DirectIndirectAssembly;
                        break;
                    case 3:
                        reportDocument.DocumentSource = null;
                        rpt_F5DirectIndirectFinish F5DirectIndirectFinish = new rpt_F5DirectIndirectFinish();
                        F5DirectIndirectFinish.year = this.yearText.Text.Trim();
                        F5DirectIndirectFinish.LoadData();
                        F5DirectIndirectFinish.CreateDocument();
                        reportDocument.DocumentSource = F5DirectIndirectFinish;
                        break;
                }                
            }  
        }

        private void buttonTurnOver_Click(object sender, EventArgs e)
        {
            frm_F5TurnOver turnoverForm = new frm_F5TurnOver();
            turnoverForm.ShowDialog();
        }

    }
}
